from collections import deque
class Solution(object):
    def dailyTemperatures(self, t):
        """
        :type T: List[int]
        :rtype: List[int]
        """
        if not t:
            return []
        stack = []
        a = [0] * len(t)
        for i in range(len(t)):
            while stack and t[stack[-1] ]< t[i]:
                cur = stack.pop()
                a[cur] = i-cur
            stack.append(i)
        return a


m = [73,74,75,71,69,72,76,73]
s = Solution()
a=s.dailyTemperatures(m)
print(a)